import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundleManager from '@ohos.bundle.bundleManager';
export function requestPermissionsFromUser(m17, ...n17) {
    return new Promise((o17, p17) => {
        let q17 = abilityAccessCtrl.createAtManager();
        q17.requestPermissionsFromUser(m17, n17).then((s17) => {
            let t17 = s17.authResults;
            let u17 = t17.length;
            for (let v17 = 0; v17 < u17; v17++) {
                if (t17[v17] === 0) {
                    o17();
                }
                else {
                    p17();
                }
            }
        }).catch((r17) => {
            console.warn(`Failed to request permissions from user. Code is ${r17.code}, message is ${r17.message}`);
            p17();
        });
    });
}
export async function checkPermissions(k17) {
    let l17 = await checkPermissionGrant(k17);
    if (l17 === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
    }
    else {
    }
}
async function checkPermissionGrant(a17) {
    let b17 = abilityAccessCtrl.createAtManager();
    let c17 = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
    let d17 = 0;
    try {
        let i17 = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
        let j17 = i17.appInfo;
        d17 = j17.accessTokenId;
    }
    catch (g17) {
        const h17 = g17;
        console.error(`Failed to get bundle info for self. Code is ${h17.code}, message is ${h17.message}`);
    }
    try {
        c17 = await b17.checkAccessToken(d17, a17);
    }
    catch (e17) {
        const f17 = e17;
        console.error(`Failed to check access token. Code is ${f17.code}, message is ${f17.message}`);
    }
    return c17;
}
